
import urllib.request


def downloadasAndroid(url):
    header = {
        "Android QQ": "User-Agent: MQQBrowser/26 Mozilla/5.0 (Linux; U; Android 2.3.7; zh-cn; MB200 Build/GRJ22; CyanogenMod-7) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"}
    request = urllib.request.Request(url, headers=header)
    request.add_header("Connection", "keep-live")
    print(request.get_full_url())  # 整个网页链接
    print(request.get_method())  # get 或者post
    response = urllib.request.urlopen(request).read().decode('utf-8')
    print(response.getinfo())  # 网页详细信息
    print(response.read())  # 网页源代码


downloadasAndroid("http://www.baidu.com/")
